package xjwt

import (
	jwt "github.com/gogf/gf-jwt/v2"
	gojwt "github.com/golang-jwt/jwt/v4"
)

// Parse 获得jwt token
func Parse(token, jwtSigningAlgorithm string, jwtKey string) (jwtToken *gojwt.Token, err error) {
	return gojwt.Parse(token, func(t *gojwt.Token) (interface{}, error) {
		if gojwt.GetSigningMethod(jwtSigningAlgorithm) != t.Method {
			return nil, jwt.ErrInvalidSigningAlgorithm
		}

		return []byte(jwtKey), nil
	})

}
